package com.wwp.tbshop.presenter;

import android.util.Log;

import com.wwp.tbshop.activity.OrderSubmitActivity;
import com.wwp.tbshop.model.bean.BaseBean;
import com.wwp.tbshop.model.bean.ConfirmBean;
import com.wwp.tbshop.util.SPUtils;

import retrofit2.Call;

/**
 * Created by ${wenping} on 6/19/2017.
 */

public class ConfirmActivityPresenter extends BasePresenter{
    
    private OrderSubmitActivity mOrderSubmitActivity;

//    private List<ConfirmBean> mConfirmBeanList;


    public ConfirmActivityPresenter(OrderSubmitActivity activity, String sku) {
        this.mOrderSubmitActivity = activity;


        // TODO: 2017/6/19  userId需要本地获取
        String userId= SPUtils.getUerid();

        // TODO: 2017/6/20 userId模拟写死 
        Call<ConfirmBean> confirmBeanCall = mApiService.getConfirmInfo(userId , sku);

        confirmBeanCall.enqueue(mCallback);
    }

    @Override
    protected void onServerBug(int code) {

    }

    @Override
    protected void onConnectError(String message) {

    }

    private static final String TAG = "ConfirmActivityPresente";

    @Override
    protected void onSuccess(BaseBean bean) {
        ConfirmBean confirmBean = (ConfirmBean) bean;
        if (confirmBean!=null){
            Log.e(TAG, confirmBean.toString() );
            mOrderSubmitActivity.getConfirmInfoSuccess(confirmBean);
        }else {
            Log.e(TAG, confirmBean.getError_code()+"");
        }
        Log.e(TAG, "onSuccess ");
    }
}
